#include<iostream>
#include<vector>
using namespace std;
typedef long long LL;
const int N = 110, mod = 1e9 + 7;
vector<int>e[N];
LL f[N];
int n, m;
LL fun(LL a, int b)
{
	LL ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans * a % mod;
		}
		a = a * a % mod;
		b >>= 1;
	}
	return ans;
}
int main()
{
	cin >> n >> m;
	while (m--) {
		int u, v;
		cin >> u >> v;
		e[u].push_back(v);
	}
	f[1] = 1;
	for (int i = 1; i < n; i++) {
		int cnt = e[i].size();
		for (int j = 0; j < cnt; j++) {
			f[e[i][j]] += f[i] * fun(cnt, mod - 2) % mod;
			f[e[i][j]] %= mod;
			//cout << "==" << endl;
		}
	}
	cout << f[n] << endl;
	//printf("%lf\n", f[n]);
	return 0;
}
